import { createBrowserRouter, Navigate } from "react-router-dom";
import App from '../App'
import { lazy, Suspense } from "react";
import { Skeleton } from 'antd';

import ProtectedRoute from '../ProtectedRoute';//路由守卫
const Three = lazy(() => import('../pages/ybk/threes'))
const Myhome = lazy(() => import('../pages/Myhome'))
//登录整体路由yf
const Login = lazy(() => import('../pages/yf/Login'))
const Shou = lazy(() => import('../pages/yf/Shuo'))
const RenLianOne = lazy(() => import('../pages/yf/RenLian'))//yf
const Renf = lazy(() => import('../pages/yf/Renf'))//yf
const Register = lazy(() => import('../pages/yf/Register'))//yf
const Yfupdate = lazy(() => import('../pages/yf/Yfupdate'))//yf

// 蔡森源整体路由
const FileUploader = lazy(() => import('../pages/Csy/FileUploader'));
const Context = lazy(() => import('../pages/Csy/Context'));
const Camera = lazy(() => import('../pages/Csy/Camera'));
const Message = lazy(() => import('../pages/Csy/message/page'))

const AI = lazy(() => import('../pages/jwh/AI'));
const My = lazy(() => import('../pages/jwh/My'))
const AppChildren = lazy(() => import('../AppChildren'))

// 服务的路由yjr
const Service = lazy(() => import("../views/yjr/service/service"));
const Integral = lazy(() => import("../views/yjr/IntegralShop/IntegralShop"));
const Order = lazy(() => import("../views/yjr/order/Order"));
const Result = lazy(() => import("../views/yjr/Result"));
const View = lazy(() => import("../views/yjr/view/View"));
const Delivery_address = lazy(() => import("../views/yjr/order/Delivery_address"));
const Add_address = lazy(() => import("../views/yjr/order/add_address"));
const Edit = lazy(() => import("../views/yjr/order/Edit"));
const More = lazy(() => import("../views/yjr/service/More"));
const Service_detail = lazy(() => import("../views/yjr/service/Details"));

// yzf路由
const Yzf_map = lazy(() => import('../pages/Fu/YzfMap.jsx'));
//wsy
const Show=lazy(()=>import('../pages/wsy/Show'))
const Tan=lazy(()=>import('../pages/wsy/Tan'))
const Time=lazy(()=>import('../pages/wsy/Time'))
const Search=lazy(()=>import("../pages/wsy/Search"))
const Xiang=lazy(()=>import('../pages/wsy/Xiang'))
const Addwsy=lazy(()=>import('../pages/wsy/Addwsy'))
const Ding=lazy(()=>import('../pages/wsy/Ding'))
const Bo=lazy(()=>import('../pages/wsy/Bo'))

const router = createBrowserRouter([
    {
        path: '/',
        element: <App />,
        children: [
            {
                path: '/',
                element: <Navigate to='/login' />
            },
            {
                path: '/login',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Login />
                    </Suspense>
                )
            },
            {
                path:'/three',
                element:(
                    <Suspense fallback={<Skeleton active/>}>
                        <Three/>
                    </Suspense>
                )
            },
            {
                path: '/shuo',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Shou />
                    </Suspense>
                )
            },
            {
                path: '/renLian',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <RenLianOne />
                    </Suspense>
                )
            },
            {
                path: '/renf',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Renf />
                    </Suspense>
                )
            },
            {
                path: '/register',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Register />
                    </Suspense>
                )
            },
            {
                path: 'yupdate',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Yfupdate />
                    </Suspense>
                )
            },
            {
                path: 'ai',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <AI />
                        </Suspense>
                    </ProtectedRoute>
                )
            },
            {
                path: 'home',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <AppChildren />
                        </Suspense>
                    </ProtectedRoute>


                ),
                children: [
                    {
                        path: 'home',
                        element: (
                            <ProtectedRoute>
                                <Suspense fallback={<Skeleton active />}>
                                    <Myhome />
                                </Suspense>
                            </ProtectedRoute>

                        )
                    },
                    {
                        path: 'show',
                        element: (
                            <ProtectedRoute>
                                <Suspense fallback={<Skeleton active />}>
                                    <Show />
                                </Suspense>
                            </ProtectedRoute>

                        )
                    },
                    {
                        path: 'my',
                        element: (
                            <ProtectedRoute>
                                <Suspense fallback={<Skeleton active />}>
                                    <My />
                                </Suspense>
                            </ProtectedRoute>

                        )
                    },
                    {
                        path: "service",
                        element: (
                            <ProtectedRoute>

                                <Suspense fallback={<Skeleton active />}>
                                    <Service />
                                </Suspense>
                            </ProtectedRoute>

                        )
                    },
                    {
                        path: 'message',
                        element: (
                            <ProtectedRoute>
                                <Suspense fallback={<Skeleton active />}>
                                    <Message />
                                </Suspense>
                            </ProtectedRoute>

                        )
                    },
                    // 杨章富地图

                    {
                        path: 'fileUploader',
                        element: (
                            <Suspense fallback={<Skeleton active />}>
                                <FileUploader />
                            </Suspense>
                        )
                    },

                ]
            },
            {
                path: '/yzfmap',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Yzf_map />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/integral',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Integral />
                    </Suspense>

                )
            },
            {
                path: '/details/:id',
                element: (
                    <Suspense fallback={<Skeleton active />}>
                        <Service_detail />
                    </Suspense>
                )
            },
            {
                path: '/order/:id',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Order />
                        </Suspense>
                    </ProtectedRoute>
                )
            },
            {
                path: '/result',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Result />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/view',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <View />
                        </Suspense>
                    </ProtectedRoute>
                )
            },
            {
                path: '/delivery_address',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Delivery_address />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/edit/:id',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Edit />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/more',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <More />
                        </Suspense>
                    </ProtectedRoute>


                )
            },
            {
                path: '/fileUploader',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <FileUploader />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/add_address',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Add_address />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/context',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Context />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path: '/Camera',
                element: (
                    <ProtectedRoute>
                        <Suspense fallback={<Skeleton active />}>
                            <Camera />
                        </Suspense>
                    </ProtectedRoute>

                )
            },
            {
                path:'/tan',
                element:(
                <Suspense fallback={<Skeleton active/>}>
                    <Tan/>
                </Suspense>)
            },
            {
                path:'/time',
                element:<Time/>
            },
            {
                path:'/search',
                element:<Search/>
            },
            {
                path:'/xiang',
                element:<Xiang/>
            },
            {
                path:'/addwsy',
                element:<Addwsy/>
            },
            {
                path:'/ding',
                element:<Ding/>
            },
            {
                path:'/bo',
                element:<Bo/>
            }

        ]

    },


]);

export default router;